package com.cskaoyan.controller;

import com.cskaoyan.bean.CskaoyanmallComment;
import com.cskaoyan.service.CskaoyanmallCommentService;
import com.cskaoyan.vo.BaseRespVo;

import com.cskaoyan.vo.CommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommentController {
    @Autowired
    CskaoyanmallCommentService service;

    //http://182.92.235.201:8083/admin/comment/list?page=1&limit=20&sort=add_time&order=desc
    @RequestMapping("admin/comment/list")
    public BaseRespVo list(Integer page, Integer limit, Integer userId, Integer valueId, String sort, String order) {
        if (userId == null && valueId == null){
            CommentVo commentVo = service.query(page, limit, sort, order);
            return BaseRespVo.ok(commentVo);
        }else {
            CommentVo commentVo = service.select(page,limit,userId,valueId,sort,order);
            return BaseRespVo.ok(commentVo);
        }
    }

  /*  //http://182.92.235.201:8083/admin/comment/list?page=1&limit=20&userId=&valueId=&sort=add_time&order=desc
    @RequestMapping("admin/comment/list")
    public BaseRespVo list(Integer page, Integer limit, Integer userId,Integer valueId, String sort, String order) {
        CommentVo commentVo = service.select(page,limit,userId,valueId,sort,order);
        return BaseRespVo.ok(commentVo);
    }*/

    //http://localhost:8083/admin/comment/delete
    @RequestMapping("admin/comment/delete")
    public BaseRespVo delete(@RequestBody CskaoyanmallComment cskaoyanmallComment) {
        int delete = service.delete(cskaoyanmallComment);
        if ( delete ==0 ){
            return BaseRespVo.ok();
        }else{
            return BaseRespVo.erro(662,"删除失败");
        }

    }

    @RequestMapping("admin/order/reply")
    public BaseRespVo reply(){
        return BaseRespVo.erro(662,"订单商品已回复！");
    }


}
